<?php

namespace common\entities\cms;

use common\entities\cms\DirEntity;

class ArticleEntity extends \common\entities\ConfigEntity
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'myscrm_cms_article';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['title'], 'required'],
            [['created_time', 'modified_time', 'pv', 'share_num', 'status', 'sort'], 'integer'],
            [['content','title','tag'], 'string'],
            [['created_by', 'modified_by'], 'string', 'max' => 50]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'dir_id' => 'dir ID',
            'created_time' => 'Created on',
            'created_by' => 'Created By',
            'modified_time' => 'Modified On',
            'modified_by' => 'Modified By',
        ];
    }    
    
    public function getDir() {
        return $this->hasOne(DirEntity::className(), ['id' => 'dir_id']);
    }    

}